
{include file="pageheader.htm"}

<script src="js/utils.js" ></script>

{if $isEditable}

<form method="post" action="?page=products&action=save&id={$product.products_id}" name="theForm" >

{/if}

  <!-- start order view -->
  <div class="list-div" id="listDiv">					  

<table cellpadding="3" cellspacing="1">

  <tr>
    <td >{$lang.record_id}</td>
    <td >{$product.products_id}</td>
    <td >{$lang.is_gift}</td>    
    <td>{html_radios name="is_gift" options=$radios_gift checked=$product.is_gift} </td>
  <tr>


	<tr>
		<td>{$lang.products_price}</td>
		<td>{if $isEditable} <input type=text name="products_price" value="{$product.products_price}" />{else}{$product.price}{/if}</td>
		<td>{$lang.member_price}</td>
		<td>{if $isEditable} <input type=text name="member_price" value= "{$product.products_memberprice}" />{else}{$product.memberprice}{/if}</td>
	</tr>  

	<tr>
		<td>{$lang.products_logo}</td>
		<td>{if $product.products_logo }<img src="{$product.products_logo}" />{/if}</td>
		<td colspan=2 >{if $isEditable} <input type=file name="product_logo" value= "{$product.product_logo}" />{/if}</td>
	</tr>

	{if $isEditable}

	<tr>
	<td >{$lang.language}</td> 
    <td>{html_options name="language_name" values=$options_language_names output=$options_language_names selected=$product.language}<input type=button value="{$lang.add_language}" onclick="addOtherLang();" /> </td> 
	<td></td>
	<td></td>
	</tr>

	{/if}

</tr>

</table>
<!-- end order view -->
</div>	

<br >
 <!-- start product language info -->
  <div class="list-div" id="idLanguageDiv">					  

  {foreach key=id item=value from=$product.infos}

  <div id="idProductInfo_{$id}" >
    
	<table cellpadding="3" cellspacing="1">

	  <tr>
		<td width=50 >{$lang.language}</td>
		<td><input type=text style="border-width:0px" readonly="readonly" name="language[]" value="{$id}" > </span></td>
		<td width=50 ></td>    

		<td> {if $isEditable}<input type=button value="remove this" onclick="removeLang('{$id}');" />{/if} </td> 
	  <tr>
	  
	  <tr>
		<td>{$lang.products_name}</td>
		<td colspan=3 >
		{if $isEditable}<input type=text name="products_name[]" value="{$value.name}" />{else} {$value.name} {/if}</td>
	  </tr>

	</table>
	<!-- end order view -->
</div>
<br >

{/foreach}

</div>

{if $isEditable }
<div class="list-div" id=idFormSubmit  >
<table>
<tr><td align=center ><input type=submit name=submit value="{$lang.submit}" ></td></tr>
</table>
</div>

</form>



<script>

var str = '<table cellpadding="3" cellspacing="1">'
+'     <tr>'
+'		<td width=50 >{$lang.language}</td>'
+'		<td><input type=text style="border-width:0px" readonly="readonly" name="language[]" value="" > </span></td>'
+'		<td width=50 ></td>'
+'		<td><input type=button value="remove this" /> </td> '
+'	  <tr>'
+'	  <tr>'
+'		<td>{$lang.products_name}</td>'
+'		<td colspan=3 >'
+'		<input type=text name="products_name[]" /></td>'
+'	  </tr>'
+'	</table> <br>	';

{literal}

function removeLang(lang)
{
	var d = document.getElementById('idLanguageDiv');
	var olddiv = document.getElementById("idProductInfo_" + lang);	
	d.removeChild(olddiv);
}


function addOtherLang()
{
	/// check the existed language version, if there is a unused item then add the table 
	/// or alert a message.

	var lang = document.theForm.language_name.value;
	var check = document.getElementById("idProductInfo_" + lang);

	if(check != null){
		alert("Already have a same language");
		return ;
	}else{
		var box = document.getElementById("idLanguageDiv");
	    check = document.createElement("div");
		check.innerHTML = str;
		check.setAttribute('id', "idProductInfo_" + lang);

		check.getElementsByTagName("input")[0].value = lang;
		check.getElementsByTagName("input")[1].onclick = function(){ removeLang(lang);}

		box.appendChild(check);
	}	
}

{/literal}
</script> 

{/if}



{include file="pagefooter.htm"}